#include<stdio.h>
#include<stdlib.h>

int main()
{
	int i,j,n;
	scanf("%d",&n);

	int *p = (int *)malloc(sizeof(int)*n);
	int *q = (int *)malloc(sizeof(int)*n);
	int *h = (int *)malloc(sizeof(int)*n);
	
	for(i = 0;i < n;i++)
	{
		scanf("%d",&p[i]);
	}
	for(j = 0;j < n;j++)
	{
		scanf("%d",&q[j]);
	}
	
	i = 0;
	j = 0;
	int k = 0;
	while(k < n)
	{
		if(p[i] < q[j])
		{
			h[k++] = p[i++];
		}
		else
		{
			h[k++] = q[j++];
		}
	}
	
	printf("%d",h[n -1]);
	
    free(p);
    free(q);
    free(h);

	return 0;
}